﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using SqlMiM.ViewModel;
using SqlMiM.Common.Framework.Options;

namespace SqlMiM.Views
{
    /// <summary>
    /// Interaction logic for OptionsView.xaml
    /// </summary>
    public partial class OptionsView : Window
    {
        private OptionsViewModel viewModel;

        public OptionsView()
        {
            InitializeComponent();

            viewModel = new OptionsViewModel();
            this.DataContext = viewModel;

            viewModel.CloseRequest += new EventHandler(viewModel_CloseRequest);

            this.Closed += new EventHandler(OptionsView_Closed);
        }

        /// <summary>
        /// Hack . Dont know how to do this in View Model
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void OptionsView_Closed(object sender, EventArgs e)
        {
            OptionsService.Current.Cancel();
        }

        void viewModel_CloseRequest(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
